// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose: implementation of CXFormsParseContextualValue.
//   $Id$
#include "stdafx.h"
#include "xformsparsecontextualvalue.h"
#include "ImplContextualValue.h"
CXFormsParseContextualValue::CXFormsParseContextualValue(bool bAllowSimpleValue,BSTR sAttr)
	:m_bAllowSimpleValue(bAllowSimpleValue)
	,m_sAttributeName(sAttr)
{
}

CXFormsParseContextualValue::~CXFormsParseContextualValue(void)
{
}

HRESULT CXFormsParseContextualValue::parse(CImplContextualValue * pCV, IHTMLElement * pElem)
{
	CComVariant vtTemp;
	pElem->getAttribute(m_sAttributeName,1,&vtTemp);
	if(vtTemp.vt == VT_BSTR)
		vtTemp.CopyTo(&pCV->m_sValueExpression);
	if(m_bAllowSimpleValue)
		pElem->get_innerHTML(&pCV->m_sSimpleValue);
	if(!pCV->m_sValueExpression && !pCV->m_sSimpleValue)
	{
		pCV->m_sValueExpression = L".";
	}
	return S_OK;
}